#!/bin/bash
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
tar -Jxf mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
mv ~/mysql-8.0.31-linux-glibc2.12-x86_64 /usr/local
cd /usr/local
mv mysql-8.0.31-linux-glibc2.12-x86_64 mysql
groupadd mysql && useradd -r -g mysql mysql
mkdir -p /data/mysql
chown mysql:mysql -R /data/mysql
echo '[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
# character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
[client]
port=3306
default-character-set=utf8
socket=/tmp/mysql.sock' >/etc/my.cnf
cd /usr/local/mysql/bin
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize-insecure
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
/etc/init.d/mysql.server start
./mysqladmin -S /tmp/mysql.sock -u root password ""
update-rc.d mysql.server defaults
apt update
apt install mysql-client-core-8.0

